#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include"commencer_le_jeu.h"
#include "afficher_instruction.h"

int menu()
{
    SDL_Surface *ecran = NULL, *imageDeFond = NULL,*menu11=NULL,*menu22=NULL,*menu33=NULL,*menu44=NULL,*imageinstruction;
    SDL_Rect positionFond;
    int continuer=1,i=1;
    positionFond.x = 0;
    positionFond.y = 0;
    SDL_Event event;
    imageinstruction=SDL_LoadBMP("imageinstruction.bmp");
    const char* musiquePath;
    musiquePath = "musique.mp3";
    SDL_Init(SDL_INIT_VIDEO);
    ecran = SDL_SetVideoMode(1024, 768, 32, SDL_HWSURFACE |SDL_DOUBLEBUF | SDL_FULLSCREEN);
    SDL_WM_SetCaption("Chargement d'images en SDL", NULL);
    menu11=SDL_LoadBMP("jouer.bmp");
    menu22=SDL_LoadBMP("option.bmp");
    menu33=SDL_LoadBMP("instruction.bmp");
    menu44=SDL_LoadBMP("quitter.bmp");
    SDL_BlitSurface(menu11, NULL, ecran, NULL);
    SDL_Flip(ecran);
    while (continuer)
    {
        SDL_WaitEvent(&event);
        switch(event.type)
        {
        case SDL_QUIT:
            continuer = 0;
            break;
        case SDL_KEYDOWN:
            switch (event.key.keysym.sym)
            {
            case SDLK_ESCAPE:
                continuer = 0;
                break;
            case SDLK_DOWN:
                i++;
                break;
            case SDLK_UP:
                i--;
                break;
            }
            break;
        }
        if(i==1)
        {
            SDL_BlitSurface(menu11,NULL,ecran,NULL);
            SDL_Flip(ecran);
            switch(event.key.keysym.sym)
            {
            case SDLK_RETURN:
                bouger();
                break;
            }
        }
        if(i==2)
        {
            SDL_BlitSurface(menu22,NULL,ecran,NULL);
            SDL_Flip(ecran);
        }
        if(i==3)
        {
            SDL_BlitSurface(menu33,NULL,ecran,NULL);
            SDL_Flip(ecran);
            switch(event.key.keysym.sym)
            {
            case SDLK_RETURN:
                afficher_instruction_jeu();

                break;
            }
        }
        if(i==4)
        {
            SDL_BlitSurface(menu44,NULL,ecran,NULL);
            SDL_Flip(ecran);
            switch(event.type)
            {
            case SDL_KEYDOWN:
                switch (event.key.keysym.sym)
                {
                case SDLK_RETURN:
                    continuer=0;
                    break;
                }
                break;
            }
        }
        if (i>4)
            i=1;
        if(i<1)
            i=4;
    }
    SDL_Quit();
    return EXIT_SUCCESS;
}

